package bb.lanxing.lib.devices.sprint.model.impl;

import androidx.core.util.Pair;
import bb.lanxing.lib.devices.sprint.model.SprintFirmwareModel;
import java.util.HashMap;
import java.util.Map;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.subjects.BehaviorSubject;

public abstract class AbstractSprintServerFirmwareModel extends AbstractSprintFirmwareModel {
    private BehaviorSubject<Map<String, String>> firmwareSubject = BehaviorSubject.create();
    private BehaviorSubject<Pair<Boolean, String>> clientNeedUpdateSubject = BehaviorSubject.create();

    @Override
    public void subscribeFirmware(Subscriber<Map<String, String>> subscriber) {
        this.firmwareSubject.observeOn(AndroidSchedulers.mainThread()).subscribe((Subscriber<? super Map<String, String>>) subscriber);
    }

    @Override
    public void subscribeClientNeedUpdate(Subscriber<Pair<Boolean, String>> subscriber) {
        this.clientNeedUpdateSubject.observeOn(AndroidSchedulers.mainThread()).subscribe((Subscriber<? super Pair<Boolean, String>>) subscriber);
    }

    @Override
    public void onNewestFirmwareVersion(String str, String str2, String str3) {
        super.onNewestFirmwareVersion(str, str2, str3);
        HashMap hashMap = new HashMap();
        hashMap.put(SprintFirmwareModel.KEY_FIRMWARE_VERSION, str);
        hashMap.put(SprintFirmwareModel.KEY_FIRMWARE_DESC, str2);
        hashMap.put(SprintFirmwareModel.KEY_FIRMWARE_URI, str3);
        this.firmwareSubject.onNext(hashMap);
    }

    public void onClientNeedUpdate(String str) {
        this.clientNeedUpdateSubject.onNext(new Pair<>(true, str));
    }
}
